#define _CRT_SECURE_NO_WARNINGS 1
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;

const int inf = 1000000000;
const int maxn = 1050;
int ambulance[15] = { 0 };
int ToInt(string s)
{
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		ans = ans * 10 + s[i] - '0';
	}
	return ans;
}
int G[maxn][maxn];
int d[maxn][maxn];
int path[maxn][maxn];

void floyd(int n)
{
	for (int i = 0; i < maxn; i++) {
		for (int j = 0; j < maxn; j++) {
			d[i][j] = G[i][j];
		}
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (d[i][k] + d[k][j] < d[i][j]) {
					d[i][j] = d[i][k] + d[k][j];
					path[i][j] = k;
				}
			}
		}
	}
}

int count(int i, int j)
{
	//	printf("i=%d, j=%d\n",i,j);
	if (path[i][j] == -1) return 0;
	else return 1 + count(i, path[i][j]) + count(path[i][j], j);
}

vector<int> ans;
void traveral(int u, int v)
{
	if (path[u][v] == -1) return;
	traveral(u, path[u][v]);
	ans.push_back(path[u][v]);
	traveral(path[u][v], v);
}

int main()
{
	fill(path[0], path[0] + maxn * maxn, -1);
	fill(G[0], G[0] + maxn * maxn, inf);
	for (int i = 0; i < maxn; i++) {
		G[i][i] = 0;
	}
	int Ns, Na, M;
	scanf("%d%d", &Ns, &Na);
	for (int i = 1; i <= Na; i++) {
		scanf("%d", &ambulance[i]);
	}
	scanf("%d", &M);
	int u, v;
	string s1, s2;
	int distance;
	for (int i = 0; i < M; i++) {
		cin >> s1 >> s2 >> distance;
		if (s1[0] == 'A') u = Ns + ToInt(s1.substr(2, s1.size() - 2));
		else u = ToInt(s1);
		if (s2[0] == 'A') v = Ns + ToInt(s2.substr(2, s2.size() - 2));
		else v = ToInt(s2);
		G[u][v] = G[v][u] = distance;
	}
	floyd(Ns + Na);
	int K, spot;
	scanf("%d", &K);
	for (int i = 0; i < K; i++) {
		scanf("%d", &spot);
		//	printf("spot=%d\n",spot);
		int minDist = inf, maxAmbulance = -1;
		int minStreets = inf, index = -1;
		for (int j = 1; j <= Na; j++) {
			if (ambulance[j] != 0) {
				if (d[j + Ns][spot] < minDist) {
					minDist = d[j + Ns][spot];
					maxAmbulance = ambulance[j];
					minStreets = count(j + Ns, spot);
					index = j;
				}
				else if (d[j + Ns][spot] == minDist && ambulance[j] > maxAmbulance) {
					maxAmbulance = ambulance[j];
					minStreets = count(j + Ns, spot);
					index = j;
				}
				else if (d[j + Ns][spot] == minDist && ambulance[j] == maxAmbulance &&
					count(j + Ns, spot) < minStreets) {
					minStreets = count(j + Ns, spot);
					index = j;
				}
			}
		}
		if (index == -1) printf("All Busy\n");
		else {
			ans.clear();
			traveral(index + Ns, spot);
			printf("A-%d", index);
			for (int j = 0; j < ans.size(); j++) {
				if (ans[j] > Ns) printf(" A-%d", ans[j] - Ns);
				else printf(" %d", ans[j]);
			}
			printf(" %d\n", spot);
			printf("%d\n", minDist);
			ambulance[index]--;
		}
	}
	return 0;
}






